<?php
class ExposableArray implements Exposable {
  protected $data;
  public function __construct(Array $pAssocArray) {
    $this->data = $pAssocArray;    
  }
  
  public function getFields() {
    return $this->data;
  }
  
  public function __get($name) {
    return $this->data[$name];
  }
  
  /**
   * Converts associative array to exposable object or array of exposable objects
   * TODO review this method
   * @param array $pArray
   */
  public static function toExposable(Array $pArray) {
    // silly test for 2D-ness:
    if (is_array($pArray[0])) {
      $retArr = array();
      foreach( $pArray as $row ) {
        $retArr[] = new ExposableArray($row);
      }
      return $retArr;
    }
    return new ExposableArray($pArray);
  }
  
}
